﻿Public Class VirtualMachine

    Property strIP As String
    Property strUsername As String
    Property strPassword As String
    Property strMainDirectory As String

    Public Sub New(ByVal inIP As String, ByVal inUsername As String, ByVal inPassword As String, ByVal inMainDir As String)
        strIP = inIP
        strUsername = inUsername
        strPassword = inPassword
        strMainDirectory = inMainDir
    End Sub

    Public Sub New()
        strIP = ""
        strUsername = ""
        strPassword = ""
        strMainDirectory = ""
    End Sub

    Public Function GetIPForFTP() As String
        If strMainDirectory <> "" Then
            Return strIP & "/%2F" & strMainDirectory
        Else
            Return strIP
        End If
    End Function

    Public Function Load(ByVal inAppName As String, ByVal inSection As String) As Boolean
        Try
            If GetSetting(inAppName, inSection, "VirtualMachine_IP", "") <> "" Then
                strIP = GetSetting(inAppName, inSection, "VirtualMachine_IP", "")
                strUsername = GetSetting(inAppName, inSection, "VirtualMachine_Username", "")
                strPassword = GetSetting(inAppName, inSection, "VirtualMachine_Password", "")
                strMainDirectory = GetSetting(inAppName, inSection, "VirtualMachine_MainDirectory", "")
                Return True
            Else
                Return False
            End If
        Catch ex As Exception
            Return False
        End Try
    End Function

    Public Function Save(ByVal inAppName As String, ByVal inSection As String) As Boolean
        Try
            SaveSetting(inAppName, inSection, "VirtualMachine_IP", strIP)
            SaveSetting(inAppName, inSection, "VirtualMachine_Username", strUsername)
            SaveSetting(inAppName, inSection, "VirtualMachine_Password", strPassword)
            SaveSetting(inAppName, inSection, "VirtualMachine_MainDirectory", strMainDirectory)

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

End Class
